// Copyright (c) 2009 Luca Marrocco.
// Modified or written by Luca Marrocco for inclusion with codej.
// Licensed under the Apache License, Version 2.0 (the "License")
package codej.ast;

import java.util.*;

import codej.ast.*;

/** @author Luca Marrocco */
public class MethodDeclaration extends BodyDeclaration implements Documentable<MethodDeclaration> {

	private List<Annotation> annotations = new LinkedList<Annotation>();
	private List<String> Throws = new LinkedList<String>();
	private List<FormalParameter> formalParameters = new LinkedList<FormalParameter>();
	private Block block;
	private Documentation documentation;
	private String name;
	private Type type;

	public void accept(Visitor visitor) {
		visitor.visit((MethodDeclaration) this);
	}

	public MethodDeclaration addAnnotation(Annotation annotation) {
		annotations.add(annotation);
		return this;
	}

	public MethodDeclaration addFormalParameter(FormalParameter formalParameter) {
		formalParameters.add(formalParameter);

		return this;
	}

	public MethodDeclaration addModifier(Modifier modifier) {
		addChild(modifier);
		return this;
	}

	public MethodDeclaration addThrows(String Throws) {
		this.Throws.add(Throws);
		return this;
	}

	public List<Annotation> getAnnotations() {
		return annotations;
	}

	public Block getBlock() {
		return block;
	}

	public Documentation getDocumentation() {
		return documentation;
	}

	public List<FormalParameter> getFormalParamters() {
		return formalParameters;
	}

	public String getName() {
		return name;
	}

	public List<String> getThrows() {
		return Throws;
	}

	public Type getType() {
		return type;
	}

	public MethodDeclaration setBlock(Block block) {
		this.block = block;

		return this;
	}

	public MethodDeclaration setDocumentation(Documentation documentation) {
		this.documentation = documentation;
		return this;
	}

	public MethodDeclaration setName(String name) {
		this.name = name;
		return this;
	}

	public MethodDeclaration setType(Type type) {
		this.type = type;
		return this;
	}
}